package com.love.cloud.admin.controller;

import com.love.cloud.admin.api.vo.AuthVo;
import com.love.cloud.admin.service.AuthService;
import com.love.cloud.common.security.annotation.AnonymousAccess;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author hongdongqu
 */
@RestController
@RequestMapping("/auth")
@Api(tags = "认证")
public class AuthController {
    @Resource
    private AuthService authService;

    @ApiOperation(value = "获取到令牌")
    @AnonymousAccess
    @PostMapping ("/getToken")
    public Object getToken(HttpServletRequest request, @Validated({AuthVo.AllType.class}) @RequestBody AuthVo authVo){
        return authService.getToken(request,authVo);
    }


    @ApiOperation(value = "通过浙征钉id获取到token信息")
    @AnonymousAccess
    @PostMapping ("/getTokenInfoByAccountId")
    public Object getTokenInfoByAccountId(HttpServletRequest request, @Validated({AuthVo.OnlyType.class}) @RequestBody AuthVo authVo){
        return authService.getTokenInfoByAccountId(request,authVo);
    }

}
